package mcp

import (
	"project-info/src/lib"
)

// MCP内部调用接口
type MCPInternalClient struct {
	context *lib.GinContext
	manager *ToolsManager
}

// 内部工具调用结果
type MCPToolResult struct {
	Success bool        `json:"success"`
	Content string      `json:"content"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
}

// 创建MCP内部客户端
func NewMCPInternalClient(c *lib.GinContext) *MCPInternalClient {
	return &MCPInternalClient{
		context: c,
		manager: GlobalToolsManager,
	}
}

// 获取可用工具列表
func (client *MCPInternalClient) GetAvailableTools() []MCPTool {
	return client.manager.GetAllTools()
}

// 获取按分类的工具列表
func (client *MCPInternalClient) GetToolsByCategory() map[string][]MCPTool {
	return client.manager.GetToolsByCategory()
}

// 内部调用工具
func (client *MCPInternalClient) CallTool(toolName string, arguments map[string]interface{}) *MCPToolResult {
	return client.manager.CallTool(client.context, toolName, arguments)
}

// 检查工具是否存在
func (client *MCPInternalClient) HasTool(toolName string) bool {
	_, exists := client.manager.GetTool(toolName)
	return exists
}

// 获取工具定义
func (client *MCPInternalClient) GetToolDefinition(toolName string) (*ToolDefinition, bool) {
	return client.manager.GetTool(toolName)
}
